package com.hh.vietnameseproject.ui.recite

import android.view.View
import androidx.viewpager.widget.ViewPager

class CardTransformer:ViewPager.PageTransformer {
    override fun transformPage(page: View, position: Float) {
        if (position <= 0.0f) {

        //被滑动的那页，设置水平位置偏移量为0，即无偏移
            page.translationX = 0f
        } else { //未被滑动的页
            page.translationX = -page.width * position

            //缩放比例
            val scale: Float =
                (page.width - 40 * position) / page.width.toFloat()
            page.scaleX = scale
            page.scaleY = scale
            page.translationY = 40 * position
        }
    }
}